//
//  videosView.m
//  iNews
//
//  Created by lanou3g on 14-12-4.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "videosView.h"
#import "hostTableViewController.h"
#import "entrainTableViewController.h"
#import "funnyTableViewController.h"
#import "goodTableViewController.h"
@implementation videosView

- (void)dealloc
{
    [_scrollV release];
    [_segment release];
    [_host release];
    [_entrain release];
    [_funny release];
    [_good release];
    [super dealloc];
    
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
     
        
        [self addViews];
        
    }
    return self;
}


#pragma mark 添加视图
-(void)addViews{
    
    
    
    //创建segment
    NSArray *arr=@[@"热点",@"娱乐",@"搞笑",@"精品"];
    self.segment=[[[UISegmentedControl alloc]initWithItems:arr] autorelease];
    self.segment.selectedSegmentIndex=0;

    //self.segment.backgroundColor=[UIColor clearColor];//改变未选中视图颜色(背景颜色)
    self.segment.tintColor = [UIColor grayColor];
    self.segment.frame=CGRectMake(20, 64, [UIScreen mainScreen].bounds.size.width-40, 25);
    [self addSubview:self.segment];
    
    
    //创建一个ScrollView
    self.scrollV=[[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.segment.frame), [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - CGRectGetHeight(self.segment.frame)-64 -44)] autorelease];
    self.scrollV.backgroundColor=[UIColor lightGrayColor];
    //设置显示内容页数
    self.scrollV.contentSize=CGSizeMake([UIScreen mainScreen].bounds.size.width*4, [UIScreen mainScreen].bounds.size.height - CGRectGetHeight(self.segment.frame)-64 - 44) ;
    //设置滑动为分页滑动
    self.scrollV.pagingEnabled=YES;
    self.scrollV.bounces=NO;//撞到边框是否有反弹
    [self addSubview:self.scrollV];
    
    
    //添加四个tabview视图
    self.host = [[[hostTableViewController alloc] init] autorelease];
    self.host.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.scrollV.frame), CGRectGetHeight(self.scrollV.frame));
    
    [self.scrollV addSubview:self.host.tableView];
    
    
    self.entrain = [[[entrainTableViewController alloc]init] autorelease];
    self.entrain.tableView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width*1, 0, CGRectGetWidth(self.scrollV.frame), CGRectGetHeight(self.scrollV.frame));
    
    [self.scrollV addSubview:self.entrain.tableView];
    
    
    self.funny = [[[funnyTableViewController alloc] init] autorelease];
    self.funny.tableView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width*2, 0,CGRectGetWidth(self.scrollV.frame), CGRectGetHeight(self.scrollV.frame));
   
    [self.scrollV addSubview: self.funny.tableView];
    
    
    self.good = [[[goodTableViewController alloc] init] autorelease];
    self.good .tableView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width*3, 0, CGRectGetWidth(self.scrollV.frame), CGRectGetHeight(self.scrollV.frame) );
    [self.scrollV addSubview:self.good.tableView];
    
    
    
    
    


}


@end
